<?php
/**
 * Created by PhpStorm.
 * User: lijie
 * Date: 2018/10/5
 * Time: 16:06
 */
namespace app\reserve\model;

use think\Model;

class Onecardproduct extends Model{

    protected $table = "orange_onecardproduct";
    protected $autoWriteTimestamp = true;
    protected $createTime = "ctime";
    protected $updateTime = "utime";
    protected $dateFormat;
    protected $insert = ['status'=>0];

    /**
     * Notes:  添加一卡通产品
     * Create Date: 2018/10/5
     * Create by :lijie
     */
    public function addOne($param)
    {
        return $this->isUpdate(false)->save($param);
    }

    /**
     * Notes:  删除一卡通产品
     * Create Date: 2018/10/5
     * Create by :lijie
     */
    public function delOne($param)
    {
        return $this->isUpdate(true)->save(['status'=>9],['id'=>$param]);
    }

    /**
     * Notes:  编辑一卡通产品
     * Create Date: 2018/10/5
     * Create by :lijie
     */
    public function editOne($param,$where)
    {
        return $this->isUpdate(true)->save($param,$where);
    }

    /**
     * Notes:  一卡通列表产品
     * Create Date: 2018/10/5
     * Create by :lijie
     */
    public function selectOne($where,$pagenum,$listNum)
    {
        return $this->where($where)->order("ctime desc")->page($pagenum,$listNum)->select();
    }

    /**
     * Notes:  一卡通详情产品
     * Create Date: 2018/10/5
     * Create by :lijie
     */
    public function findOne($where)
    {
        return $this->where($where)->field("backmoney,description,id,name,topup")->find();
    }
}